<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>

<body class="gray-bg">
<div class="ui-layout-west">
	<div class="main-content">
		<div class="box box-main">
			<div class="box-header">
				<div class="box-title">
					<i class="fa icon-grid"></i> 物联网终端区域
				</div>
				<div class="box-tools pull-right">
					<!--<a type="button" class="btn btn-box-tool menuItem" href="#" onclick="dept()" title="管理部门"><i class="fa fa-edit"></i></a>-->
					<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
					<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
					<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新"><i class="fa fa-refresh"></i></button>
				</div>
			</div>
			<div class="ui-layout-content">
				<div id="tree" class="ztree"></div>
			</div>
		</div>
	</div>
</div>

<div class="container-div ui-layout-center">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="user-form">
				<input type="hidden" id="Aid" name="aid">
				<input type="hidden" id="Parentaid" name="parentaid">
				<div class="select-list">
					<ul>

						<li>
							地区编号：<input type="text" name="aid"/>
						</li>

						<li>
							地区名称：<input type="text" name="aname"/>
						</li>

						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
			<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="iot:area:add">
				<i class="fa fa-plus"></i> 新增
			</a>
			<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="iot:area:edit">
				<i class="fa fa-edit"></i> 修改
			</a>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('iot:area:edit')}]];
    var removeFlag = [[${@permission.hasPermi('iot:area:remove')}]];

    var datas = [[${@dict.getType('sys_normal_disable')}]];

    var prefix = ctx + "iot/area";

    $(function() {
        $('body').layout({ west__size: 185 });
        queryAreaList();
        queryAreaTree();
    });

    function queryAreaList() {
            var options = {
                url: prefix + "/list",
                // createUrl: prefix + "/add",
                // updateUrl: prefix + "/edit/{id}",
                // exportUrl: prefix + "/export",
                modalName: "终端地域",
                search: false,
                showExport: true,
                columns: [{
                    checkbox: true
                },
				{
					field : 'aid',
					title : '地域ID',
					visible: true
				},
				{
					field : 'aname',
					title : '地域名称',
					sortable: true
				}]
            };
        $.table.init(options);
    };

    function queryAreaTree()
    {
        var url = ctx + "iot/area/treeData";
        var options = {
            url: url,
            expandLevel: 2,
            onClick : zOnClick
        };
        $.tree.init(options);

        function zOnClick(event, treeId, treeNode) {
            $("#Aid").val(treeNode.id);
            $("#Parentaid").val(treeNode.pId);
            $.table.search();
        }
    }

    $('#btnExpand').click(function() {
        $._tree.expandAll(true);
        $(this).hide();
        $('#btnCollapse').show();
    });

    $('#btnCollapse').click(function() {
        $._tree.expandAll(false);
        $(this).hide();
        $('#btnExpand').show();
    });

    $('#btnRefresh').click(function() {
        queryAreaTree();
    });


</script>
</body>
</html>